<?php

// phpMyRealty 3
//
// File Name: pages.php
// File Location : ./
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// Include configuration file and general functions
define('PMR', 'true');

include ( './config.php' );
include ( PATH . '/defaults.php' );

// ----------------------------------------------------------------------

if ( eregi ('^[0-9]+$', $_GET['id']) || ( eregi ('^[0-9A-Za-z\-\_]+', $_GET['string']) ) )
{

	// Language to show article in
	$menu2 = str_replace( 'name', 'menu', $language_in );
	$text2 = str_replace( 'name', 'text', $language_in );

	if ($menu2 == '')
		$menu2 = 'menu';

	if ($text2 == '')
		$text2 = 'text';

	if ($_GET['id'] != '')
		$whereSQL = ' WHERE id = "' . safehtml($_GET['id']) . '" ';
	elseif ($_GET['string'] != '')
		$whereSQL = ' WHERE string = "' . safehtml($_GET['string']) . '" ';

	$sql = 'SELECT ' . $menu2 . ', ' . $text2 . ', id, status, string, date, menu, text FROM ' . PAGES_TABLE . $whereSQL;

	$r_pages = $db->query($sql) or error ( 'Critical Error', mysql_error () );
	$f_pages = $db->fetcharray($r_pages);

	// Default
	if ($f_pages[0] == '')
		$f_pages[0] = $f_pages[6];

	if ($f_pages[1] == '')
		$f_pages[1] = $f_pages[7];

	// Title tag content
	$title = $conf['website_name_short'] . ' - ' . $f_pages[0];

	// Template header
	include ( PATH . '/templates/' . $cookie_template . '/header.php' );

	$sql = 'SELECT ' . $menu2 . ', ' . $text2 . ', id, status, string, date, menu, text FROM ' . PAGES_TABLE . $whereSQL;
	$r_pages = $db->query($sql) or error ( 'Critical Error', mysql_error () );
	$f_pages = $db->fetcharray($r_pages);

	// Default
	if ($f_pages[0] == '')
		$f_pages[0] = $f_pages[6];

	if ($f_pages[1] == '')
		$f_pages[1] = $f_pages[7];

	echo table_header($f_pages[0]);

	if ($f_pages['status'] == 0)
		echo $lang['CMS_View_Error'];
	else
		echo unsafehtml($f_pages[1]);

	echo table_footer();

}

// Template footer
include ( PATH . '/templates/' . $cookie_template . '/footer.php' );

?>